<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form   style="height: 38px;">
            <Input v-model="auditorUser"  placeholder="按审核人查询" style="float: left;width: 200px;margin-right: 3px;"></Input>
            <Input v-model="userName" placeholder="按申请人查询" style="float: left;width: 200px;margin-right: 3px;"></Input>
            <FormItem   style="width: 200px;float: left;margin-right: 3px;" >
                <Select  v-model="auditorStatus" placeholder="请选择审核状态"  style="margin-right: 3px;">
                    <Option value="3">全部</Option>
                    <Option value="0">未审核 </Option>
                    <Option value="1">审核通过</Option>
                    <Option value="2">审核失败</Option>
                </Select>
            </FormItem>
            <FormItem   style="width: 200px;float: left;margin-right: 3px;" >
                <Select  v-model="rank"  placeholder="请选择审核级别"  style="margin-right: 3px;">
                    <Option value="0">全部</Option>
                    <Option value="1">级别一 </Option>
                    <Option value="2">级别二</Option>
                </Select>
            </FormItem>
            <div style="float: right">
                <Button type="success" style="float: right;margin-right: 5px" @click="audit">一键通过</Button>

                <Button type="info" style="float: right;margin-right: 5px" @click="load(1)">查询</Button>

            </div>
        </Form>
        <Table @on-selection-change="changeNum" :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize" show-total @on-page-size-change='pageSizes'  show-elevator show-sizer  style="text-align: center;margin-top: 15px;"  @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    import Cookies from 'js-cookie'

    export default {
        data() {
            return {
                auditorUser:'',
                userName:'',
                auditorStatus:'',
                rank:'',
                loading: true,
                Message:[],
                numArr:[],
                admin:true,
                columnsList: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '审核级别',
                        align: 'center',
                        key: 'rankName',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '申请人用户名',
                        align: 'center',
                        width:'auto',
                        key: 'userName'
                    },
                    {
                        title: '申请人真实姓名',
                        align: 'center',
                        key: 'idName'
                    },
                    {
                        title: '申请人身份证号',
                        align: 'center',
                        key: 'idNumber',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '申请人国籍',
                        align: 'center',
                        key: 'country',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '审核人',
                        align: 'center',
                        key: 'auditorUser',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '审核状态',
                        align: 'center',
                        key: 'auditorStatus',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '备注',
                        align: 'center',
                        key: 'remark',
                        width:'auto',
                        editable: true
                    },
                    {
                        title: '记录创建时间',
                        align: 'center',
                        key: 'createTime',
                        width:'140px',
                        editable: true
                    },
                    {
                        title: '审核时间',
                        align: 'center',
                        width:'auto',
                        key: 'auditorTime',
                        editable: true
                    },
                    {
                        title: '操作',
                        align: 'center',
                        width:'auto',
                        render: (h, params) => {
                            if (params.row.auditorStatus == "未审核") {
                                return h('div', [
                                    h('Button', {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            marginRight: '5px'
                                        },
                                        on: {
                                            click: () => {
                                                this.$router.push({
                                                    name: 'identityInner',
                                                    params:params
                                                });
                                            }
                                        }
                                    }, '编辑')
                                ]);
                            }
                        }
                    }
                ],
                name: '',
                pageNum:0,
                initPage:1,
                pageSize:10
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            pageSizes(val){
                this.pageSize = val
                this.$store.commit('saveIdentity', {
                    stats: this.auditorStatus,
                    dj: this.rank,
                    pg: this.pageSize
                })
                this.loading = true
                this.load()
            },
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            },
            changeNum (val){
                this.numArr = []
                for(var i = 0; i < val.length; i++){
                    this.numArr.push(val[i].id)
                }
            },
            audit(){
                let _this = this
                let params = new URLSearchParams()
                params.append('auditorUser',Cookies.get('user'))
                params.append('id', _this.numArr)
                params.append('auditorStatus','1')
                $http.post('/userBasic/auditorUserIdentity',params).then(function (res) {
                    if(res.suc){
                        _this.$Message.info('审核成功!')
                        _this.load()
                    }else{
                        _this.$Message.info('审核失败!')
                    }
                })
            },
            load (index){
                let _this = this
                let params = new URLSearchParams()
                _this.loading = true
                if(index == '1'){
                    _this.initPage = 1
                    _this.$store.commit('saveIdentity', {
                        stats: _this.auditorStatus,
                        dj: _this.rank,
                        pg: _this.pageSize
                    })
                }
                params.append('page',_this.initPage)
                _this.auditorStatus = _this.$store.state.auditorStatus
                _this.rank = _this.$store.state.rank
                _this.pageSize = _this.$store.state.pageSize
                if(_this.rank == 0){
                    params.append('rank','')
                }else{
                    params.append('rank',_this.rank)
                }
                if(_this.auditorStatus == 3){
                    params.append('auditorStatus','')
                }else{
                    params.append('auditorStatus',_this.auditorStatus)
                }
                params.append('pageSize',_this.pageSize)
                params.append('auditorUser',_this.auditorUser)
                params.append('userName',_this.userName)
                $http.post('/userBasic/selectShenFenAuditorInfoPage',params).then(function (res) {
                    if(res.suc){
                    _this.Message = res.result.list
                    _this.loading = false
                    _this.pageNum = res.result.totalRow
                }else{
                    if(res.msg == "请先登录"){
                        _this.$Message.error('请重新登录！');
                    }else{
                        _this.$Message.error(res.msg);
                    }
                }
                })
            }
        }
    }
</script>
<style>
    .ivu-form-item {
        margin-bottom: 5px !important;
    }
</style>

